<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Robocup-denayer-project-a: read-only/trunk/source/movingObject/movingObject.cpp Bron Bestand</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Gegenereerd door Doxygen 1.7.1 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Zoeken');
--></script>
<script type="text/javascript">
function hasClass(ele,cls) {
  return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}

function addClass(ele,cls) {
  if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}

function removeClass(ele,cls) {
  if (hasClass(ele,cls)) {
    var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
    ele.className=ele.className.replace(reg,' ');
  }
}

function toggleVisibility(linkObj) {
 var base = linkObj.getAttribute('id');
 var summary = document.getElementById(base + '-summary');
 var content = document.getElementById(base + '-content');
 var trigger = document.getElementById(base + '-trigger');
 if ( hasClass(linkObj,'closed') ) {
   summary.style.display = 'none';
   content.style.display = 'block';
   trigger.src = 'open.png';
   removeClass(linkObj,'closed');
   addClass(linkObj,'opened');
 } else if ( hasClass(linkObj,'opened') ) {
   summary.style.display = 'block';
   content.style.display = 'none';
   trigger.src = 'closed.png';
   removeClass(linkObj,'opened');
   addClass(linkObj,'closed');
 }
 return false;
}
</script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Hoofd&nbsp;Pagina</span></a></li>
      <li><a href="annotated.html"><span>Klassen</span></a></li>
      <li class="current"><a href="files.html"><span>Bestanden</span></a></li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
          <span class="left">
            <form id="FSearchBox" action="search.php" method="get">
              <img id="MSearchSelect" src="search/mag.png" alt=""/>
              <input type="text" id="MSearchField" name="query" value="Zoeken" size="20" accesskey="S" 
                     onfocus="searchBox.OnSearchFieldFocus(true)" 
                     onblur="searchBox.OnSearchFieldFocus(false)"/>
            </form>
          </span><span class="right"></span>
        </div>
      </li>
    </ul>
  </div>
  <div class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&nbsp;Lijst</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<h1>read-only/trunk/source/movingObject/movingObject.cpp</h1>  </div>
</div>
<div class="contents">
<a href="moving_object_8cpp.html">Ga naar de documentatie van dit bestand.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00010"></a>00010 <span class="preprocessor">#include &quot;<a class="code" href="moving_object_8h.html">movingObject.h</a>&quot;</span>
<a name="l00011"></a>00011 <span class="preprocessor">#include &lt;math.h&gt;</span>
<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00013"></a>00013 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00014"></a>00014 <span class="keyword">using namespace </span>std;
<a name="l00015"></a>00015 
<a name="l00020"></a><a class="code" href="class_moving_object.html#aa1aa21fceb845d374d19ddcaf0f3f691">00020</a> <span class="keywordtype">void</span> <a class="code" href="class_moving_object.html#aa1aa21fceb845d374d19ddcaf0f3f691" title="Zet alles op 0.">MovingObject::init</a>()
<a name="l00021"></a>00021 {
<a name="l00022"></a>00022     pthread_mutex_init(&amp;wpMutex,NULL);
<a name="l00023"></a>00023 
<a name="l00024"></a>00024     <span class="comment">// Zet 3 waypoints op 0!</span>
<a name="l00025"></a>00025     this-&gt;<a class="code" href="class_moving_object.html#ad6a22767725a14888c45af6db99353a4">setWp</a>(<a class="code" href="class_way_point.html">WayPoint</a>());
<a name="l00026"></a>00026     this-&gt;<a class="code" href="class_moving_object.html#ad6a22767725a14888c45af6db99353a4">setWp</a>(<a class="code" href="class_way_point.html">WayPoint</a>());
<a name="l00027"></a>00027     this-&gt;<a class="code" href="class_moving_object.html#ad6a22767725a14888c45af6db99353a4">setWp</a>(<a class="code" href="class_way_point.html">WayPoint</a>());
<a name="l00028"></a>00028 }
<a name="l00029"></a>00029 
<a name="l00030"></a><a class="code" href="class_moving_object.html#a72319e0ab09942537c73a26faa435633">00030</a> <a class="code" href="class_moving_object.html#a72319e0ab09942537c73a26faa435633">MovingObject::MovingObject</a>() {
<a name="l00031"></a>00031     this-&gt;<a class="code" href="class_moving_object.html#aa1aa21fceb845d374d19ddcaf0f3f691" title="Zet alles op 0.">init</a>();
<a name="l00032"></a>00032 }
<a name="l00033"></a>00033 
<a name="l00034"></a><a class="code" href="class_moving_object.html#a2ec2976b37b76400169f3d796af39b5f">00034</a> <a class="code" href="class_moving_object.html#a72319e0ab09942537c73a26faa435633">MovingObject::MovingObject</a>(<span class="keywordtype">string</span> <span class="keywordtype">id</span>){
<a name="l00035"></a>00035     <a class="code" href="class_moving_object.html#aa1aa21fceb845d374d19ddcaf0f3f691" title="Zet alles op 0.">init</a>();
<a name="l00036"></a>00036     this-&gt;<a class="code" href="class_moving_object.html#a176a309e75177bf59418d35603c7e704">setID</a>(<span class="keywordtype">id</span>);
<a name="l00037"></a>00037 }
<a name="l00038"></a>00038 
<a name="l00039"></a><a class="code" href="class_moving_object.html#aa6b998b1ae0d294aa651a3d747335f73">00039</a> <a class="code" href="class_moving_object.html#aa6b998b1ae0d294aa651a3d747335f73">MovingObject::~MovingObject</a>() {
<a name="l00040"></a>00040         <span class="comment">// TODO Auto-generated destructor stub</span>
<a name="l00041"></a>00041 }
<a name="l00042"></a>00042 
<a name="l00043"></a>00043 
<a name="l00044"></a>00044 
<a name="l00045"></a><a class="code" href="class_moving_object.html#ad6a22767725a14888c45af6db99353a4">00045</a> <span class="keywordtype">void</span> <a class="code" href="class_moving_object.html#ad6a22767725a14888c45af6db99353a4">MovingObject::setWp</a>(<a class="code" href="class_way_point.html">WayPoint</a> wp) {
<a name="l00046"></a>00046         <span class="comment">// lock mutex, to prevent writing and reading waypoints at the same time</span>
<a name="l00047"></a>00047         <a class="code" href="thread_8cpp.html#a2fa7d525ff3fefb8266255563ae8896b" title="Probeer de lock op object te krijgen.">mutex_lock</a>(&amp;wpMutex);
<a name="l00048"></a>00048 
<a name="l00049"></a>00049         wpPrev2_ = wpPrev_;
<a name="l00050"></a>00050         wpPrev_ = wp_;
<a name="l00051"></a>00051         wp_ = wp;
<a name="l00052"></a>00052 
<a name="l00053"></a>00053         <span class="comment">// Unlock mutex</span>
<a name="l00054"></a>00054         <a class="code" href="thread_8cpp.html#ae9cd60f1fa40bbc5b3c312493f0ea89f">mutex_unlock</a>(&amp;wpMutex);
<a name="l00055"></a>00055 }
<a name="l00056"></a>00056 
<a name="l00057"></a><a class="code" href="class_moving_object.html#a51fd06046cbdff9cd1100b80e5b7e951">00057</a> <a class="code" href="class_way_point.html">WayPoint</a> <a class="code" href="class_moving_object.html#a51fd06046cbdff9cd1100b80e5b7e951">MovingObject::getWp</a>() {
<a name="l00058"></a>00058         <span class="comment">// lock mutex, to prevent writing and reading waypoints at the same time</span>
<a name="l00059"></a>00059 
<a name="l00060"></a>00060         <a class="code" href="thread_8cpp.html#a2fa7d525ff3fefb8266255563ae8896b" title="Probeer de lock op object te krijgen.">mutex_lock</a>(&amp;wpMutex);
<a name="l00061"></a>00061         <span class="comment">//printf(&quot;Zet lock op: done\n&quot;);</span>
<a name="l00062"></a>00062         <span class="comment">// Haal waypoint</span>
<a name="l00063"></a>00063         <a class="code" href="class_way_point.html">WayPoint</a> wp = wp_;
<a name="l00064"></a>00064 
<a name="l00065"></a>00065         <span class="comment">// Unlock mutex</span>
<a name="l00066"></a>00066         <a class="code" href="thread_8cpp.html#ae9cd60f1fa40bbc5b3c312493f0ea89f">mutex_unlock</a>(&amp;wpMutex);
<a name="l00067"></a>00067 
<a name="l00068"></a>00068         <span class="keywordflow">return</span> wp;
<a name="l00069"></a>00069 }
<a name="l00070"></a>00070 
<a name="l00075"></a><a class="code" href="class_moving_object.html#a1eb2f2d58594bd1ed53928d6cbfcdded">00075</a> <a class="code" href="class_way_point.html">WayPoint</a> <a class="code" href="class_moving_object.html#a1eb2f2d58594bd1ed53928d6cbfcdded" title="Get vorige waypoint.">MovingObject::getWpPrev</a>() {
<a name="l00076"></a>00076         <span class="comment">// lock mutex, to prevent writing and reading waypoints at the same time</span>
<a name="l00077"></a>00077         <a class="code" href="thread_8cpp.html#a2fa7d525ff3fefb8266255563ae8896b" title="Probeer de lock op object te krijgen.">mutex_lock</a>(&amp;wpMutex);
<a name="l00078"></a>00078 
<a name="l00079"></a>00079         <span class="comment">// Haal waypoint</span>
<a name="l00080"></a>00080         <a class="code" href="class_way_point.html">WayPoint</a> wp = wpPrev_;
<a name="l00081"></a>00081 
<a name="l00082"></a>00082         <span class="comment">// Unlock mutex</span>
<a name="l00083"></a>00083         <a class="code" href="thread_8cpp.html#ae9cd60f1fa40bbc5b3c312493f0ea89f">mutex_unlock</a>(&amp;wpMutex);
<a name="l00084"></a>00084 
<a name="l00085"></a>00085         <span class="keywordflow">return</span> wp;
<a name="l00086"></a>00086 }
<a name="l00087"></a>00087 
<a name="l00088"></a>00088 
<a name="l00089"></a><a class="code" href="class_moving_object.html#afef2937b5fc462e83804628e94b17179">00089</a> <span class="keywordtype">void</span> <a class="code" href="class_moving_object.html#afef2937b5fc462e83804628e94b17179">MovingObject::setWpGoal</a>(<a class="code" href="class_way_point.html">WayPoint</a> goal) {
<a name="l00090"></a>00090     <span class="comment">// lock mutex, to prevent writing and reading waypoints at the same time</span>
<a name="l00091"></a>00091     <a class="code" href="thread_8cpp.html#a2fa7d525ff3fefb8266255563ae8896b" title="Probeer de lock op object te krijgen.">mutex_lock</a>(&amp;wpMutex);
<a name="l00092"></a>00092 
<a name="l00093"></a>00093     this-&gt;wpGoal = goal;
<a name="l00094"></a>00094 
<a name="l00095"></a>00095     <span class="comment">// Unlock mutex</span>
<a name="l00096"></a>00096     <a class="code" href="thread_8cpp.html#ae9cd60f1fa40bbc5b3c312493f0ea89f">mutex_unlock</a>(&amp;wpMutex);
<a name="l00097"></a>00097 }
<a name="l00098"></a>00098 
<a name="l00099"></a><a class="code" href="class_moving_object.html#a6928b4124addab86f23e5a936ee641aa">00099</a> <a class="code" href="class_way_point.html">WayPoint</a> <a class="code" href="class_moving_object.html#a6928b4124addab86f23e5a936ee641aa">MovingObject::getWpGoal</a>(){
<a name="l00100"></a>00100     <span class="comment">// lock mutex, to prevent writing and reading waypoints at the same time</span>
<a name="l00101"></a>00101     <a class="code" href="thread_8cpp.html#a2fa7d525ff3fefb8266255563ae8896b" title="Probeer de lock op object te krijgen.">mutex_lock</a>(&amp;wpMutex);
<a name="l00102"></a>00102 
<a name="l00103"></a>00103     <span class="comment">// Haal waypoint</span>
<a name="l00104"></a>00104     <a class="code" href="class_way_point.html">WayPoint</a> wp = wpGoal;
<a name="l00105"></a>00105 
<a name="l00106"></a>00106     <span class="comment">// Unlock mutex</span>
<a name="l00107"></a>00107     <a class="code" href="thread_8cpp.html#ae9cd60f1fa40bbc5b3c312493f0ea89f">mutex_unlock</a>(&amp;wpMutex);
<a name="l00108"></a>00108 
<a name="l00109"></a>00109     <span class="keywordflow">return</span> wp;
<a name="l00110"></a>00110 }
<a name="l00111"></a>00111 
<a name="l00112"></a><a class="code" href="class_moving_object.html#a176a309e75177bf59418d35603c7e704">00112</a> <span class="keywordtype">void</span> <a class="code" href="class_moving_object.html#a176a309e75177bf59418d35603c7e704">MovingObject::setID</a>(<span class="keywordtype">string</span> <span class="keywordtype">id</span>){
<a name="l00113"></a>00113     this-&gt;<span class="keywordtype">id</span> = id;
<a name="l00114"></a>00114 }
<a name="l00115"></a>00115 
<a name="l00116"></a><a class="code" href="class_moving_object.html#ab86a215ad2a3760bee9ef4f4cf51647c">00116</a> <span class="keywordtype">string</span> <a class="code" href="class_moving_object.html#ab86a215ad2a3760bee9ef4f4cf51647c">MovingObject::getID</a>(){
<a name="l00117"></a>00117     <span class="keywordflow">return</span> this-&gt;id;
<a name="l00118"></a>00118 }
<a name="l00119"></a>00119 
<a name="l00120"></a><a class="code" href="class_moving_object.html#a6e7fed1c00f986d7f8a87545f43ba3fa">00120</a> <a class="code" href="class_way_point.html">WayPoint</a> <a class="code" href="class_moving_object.html#a6e7fed1c00f986d7f8a87545f43ba3fa">MovingObject::getWpNext</a>(<span class="keywordtype">double</span> t) {
<a name="l00121"></a>00121 
<a name="l00122"></a>00122         <span class="comment">//Declaring local variables</span>
<a name="l00123"></a>00123         <span class="keywordtype">int</span> xdif;
<a name="l00124"></a>00124         <span class="keywordtype">int</span> ydif;
<a name="l00125"></a>00125         <span class="keywordtype">double</span> timedif;
<a name="l00126"></a>00126         <span class="keywordtype">float</span> velocityX;
<a name="l00127"></a>00127         <span class="keywordtype">float</span> velocityY;
<a name="l00128"></a>00128         <span class="keywordtype">int</span> goDistanceX;
<a name="l00129"></a>00129         <span class="keywordtype">int</span> goDistanceY;
<a name="l00130"></a>00130         <span class="keywordtype">int</span> futureX;
<a name="l00131"></a>00131         <span class="keywordtype">int</span> futureY;
<a name="l00132"></a>00132         <span class="keywordtype">float</span> futureTheta;
<a name="l00133"></a>00133         <a class="code" href="class_way_point.html">WayPoint</a> wpFuture_;
<a name="l00134"></a>00134         <a class="code" href="class_way_point.html">WayPoint</a> wp;
<a name="l00135"></a>00135         <a class="code" href="class_way_point.html">WayPoint</a> wpprev;
<a name="l00136"></a>00136 
<a name="l00137"></a>00137         wp = this-&gt;<a class="code" href="class_moving_object.html#a51fd06046cbdff9cd1100b80e5b7e951">getWp</a>();
<a name="l00138"></a>00138         wpprev = this-&gt;<a class="code" href="class_moving_object.html#a1eb2f2d58594bd1ed53928d6cbfcdded" title="Get vorige waypoint.">getWpPrev</a>();
<a name="l00139"></a>00139 
<a name="l00140"></a>00140 
<a name="l00141"></a>00141         <span class="comment">//Calculating the distance</span>
<a name="l00142"></a>00142         xdif = wp.<a class="code" href="class_way_point.html#af8e925a0c05154820837e21852cf08a5" title="Get X-coordinaat.">getX</a>() - wpprev.<a class="code" href="class_way_point.html#af8e925a0c05154820837e21852cf08a5" title="Get X-coordinaat.">getX</a>();
<a name="l00143"></a>00143         ydif = wp.<a class="code" href="class_way_point.html#abf3b2046af024d6b2c50aacc82175b05">getY</a>() - wpprev.<a class="code" href="class_way_point.html#abf3b2046af024d6b2c50aacc82175b05">getY</a>();
<a name="l00144"></a>00144 
<a name="l00145"></a>00145         <span class="keywordflow">if</span>(xdif == 0 &amp;&amp; ydif == 0)
<a name="l00146"></a>00146         {
<a name="l00147"></a>00147             wpFuture_.<a class="code" href="class_way_point.html#a89c261b669af94fe8b51903d1337f972" title="Zet X-coordinaat.">setX</a>(wp.<a class="code" href="class_way_point.html#af8e925a0c05154820837e21852cf08a5" title="Get X-coordinaat.">getX</a>());
<a name="l00148"></a>00148             wpFuture_.<a class="code" href="class_way_point.html#a4fb0098a46a3a5e3110820c3647f9f00">setY</a>(wp.<a class="code" href="class_way_point.html#af8e925a0c05154820837e21852cf08a5" title="Get X-coordinaat.">getX</a>());
<a name="l00149"></a>00149             wpFuture_.<a class="code" href="class_way_point.html#ae453bbb3f53e6f4617abada193b6340d" title="Zet de hoek in radialen.">setTheta</a>(wp.<a class="code" href="class_way_point.html#af8e925a0c05154820837e21852cf08a5" title="Get X-coordinaat.">getX</a>());
<a name="l00150"></a>00150 
<a name="l00151"></a>00151             <span class="keywordflow">return</span> wpFuture_;
<a name="l00152"></a>00152         }
<a name="l00153"></a>00153         <span class="comment">//Calculating the timedifference</span>
<a name="l00154"></a>00154         timedif = wp.<a class="code" href="class_way_point.html#a20701a3113324659d7f7d71c39d0aa1d">getTimeStamp</a>() - wpprev.<a class="code" href="class_way_point.html#a20701a3113324659d7f7d71c39d0aa1d">getTimeStamp</a>();
<a name="l00155"></a>00155 
<a name="l00156"></a>00156         <span class="comment">//Computing the velocity</span>
<a name="l00157"></a>00157         velocityX = xdif / timedif;
<a name="l00158"></a>00158         velocityY = ydif / timedif;
<a name="l00159"></a>00159 
<a name="l00160"></a>00160         <span class="comment">//Distance in a given time</span>
<a name="l00161"></a>00161         goDistanceX = velocityX * t;
<a name="l00162"></a>00162         goDistanceY = velocityY * t;
<a name="l00163"></a>00163         futureX = wp.<a class="code" href="class_way_point.html#af8e925a0c05154820837e21852cf08a5" title="Get X-coordinaat.">getX</a>() + goDistanceX;
<a name="l00164"></a>00164         futureY = wp.<a class="code" href="class_way_point.html#abf3b2046af024d6b2c50aacc82175b05">getY</a>() + goDistanceY;
<a name="l00165"></a>00165 
<a name="l00166"></a>00166         <span class="comment">// Calculate the new theta</span>
<a name="l00167"></a>00167         <span class="keywordflow">if</span>(xdif == 0)
<a name="l00168"></a>00168         {
<a name="l00169"></a>00169             futureTheta = (ydif &gt; 0) ? M_PI/2 : -M_PI/2 ;
<a name="l00170"></a>00170         }
<a name="l00171"></a>00171         <span class="keywordflow">else</span>
<a name="l00172"></a>00172         {
<a name="l00173"></a>00173             futureTheta = atan(ydif/xdif);
<a name="l00174"></a>00174         }
<a name="l00175"></a>00175 
<a name="l00176"></a>00176         <span class="comment">//Set futureX and futureY in a new WayPoint</span>
<a name="l00177"></a>00177         wpFuture_.<a class="code" href="class_way_point.html#a89c261b669af94fe8b51903d1337f972" title="Zet X-coordinaat.">setX</a>(futureX);
<a name="l00178"></a>00178         wpFuture_.<a class="code" href="class_way_point.html#a4fb0098a46a3a5e3110820c3647f9f00">setY</a>(futureY);
<a name="l00179"></a>00179         wpFuture_.<a class="code" href="class_way_point.html#ae453bbb3f53e6f4617abada193b6340d" title="Zet de hoek in radialen.">setTheta</a>(futureTheta);
<a name="l00180"></a>00180 
<a name="l00181"></a>00181         <span class="comment">//Return next WayPoint estimate</span>
<a name="l00182"></a>00182         <span class="keywordflow">return</span> wpFuture_;
<a name="l00183"></a>00183 }
<a name="l00184"></a>00184 
<a name="l00196"></a><a class="code" href="class_moving_object.html#a03e69eb416f7ba6a15fca179fd404905">00196</a> <a class="code" href="class_way_point.html">WayPoint</a> <a class="code" href="class_moving_object.html#a03e69eb416f7ba6a15fca179fd404905" title="Bereken snijpunt van dit object en een ander.">MovingObject::getWpIntersection</a>(<a class="code" href="class_moving_object.html">MovingObject</a> mo2){
<a name="l00197"></a>00197     
<a name="l00198"></a>00198     <span class="comment">// Zie http://www.ahristov.com/tutorial/geometry-games/intersection-lines.html</span>
<a name="l00199"></a>00199 
<a name="l00200"></a>00200     <span class="keywordtype">int</span> x1,y1,x2,y2,x3,y3,x4,y4;
<a name="l00201"></a>00201     <span class="keywordtype">int</span> xr,yr;                      <span class="comment">//Resultaat</span>
<a name="l00202"></a>00202 
<a name="l00203"></a>00203     x1 = this-&gt;<a class="code" href="class_moving_object.html#a1eb2f2d58594bd1ed53928d6cbfcdded" title="Get vorige waypoint.">getWpPrev</a>().<a class="code" href="class_way_point.html#af8e925a0c05154820837e21852cf08a5" title="Get X-coordinaat.">getX</a>();
<a name="l00204"></a>00204     y1 = this-&gt;<a class="code" href="class_moving_object.html#a1eb2f2d58594bd1ed53928d6cbfcdded" title="Get vorige waypoint.">getWpPrev</a>().<a class="code" href="class_way_point.html#abf3b2046af024d6b2c50aacc82175b05">getY</a>();
<a name="l00205"></a>00205 
<a name="l00206"></a>00206     x2 = this-&gt;<a class="code" href="class_moving_object.html#a51fd06046cbdff9cd1100b80e5b7e951">getWp</a>().<a class="code" href="class_way_point.html#af8e925a0c05154820837e21852cf08a5" title="Get X-coordinaat.">getX</a>();
<a name="l00207"></a>00207     y2 = this-&gt;<a class="code" href="class_moving_object.html#a51fd06046cbdff9cd1100b80e5b7e951">getWp</a>().<a class="code" href="class_way_point.html#abf3b2046af024d6b2c50aacc82175b05">getY</a>();
<a name="l00208"></a>00208 
<a name="l00209"></a>00209     x3 = mo2.<a class="code" href="class_moving_object.html#a1eb2f2d58594bd1ed53928d6cbfcdded" title="Get vorige waypoint.">getWpPrev</a>().<a class="code" href="class_way_point.html#af8e925a0c05154820837e21852cf08a5" title="Get X-coordinaat.">getX</a>();
<a name="l00210"></a>00210     y3 = mo2.<a class="code" href="class_moving_object.html#a1eb2f2d58594bd1ed53928d6cbfcdded" title="Get vorige waypoint.">getWpPrev</a>().<a class="code" href="class_way_point.html#abf3b2046af024d6b2c50aacc82175b05">getY</a>();
<a name="l00211"></a>00211 
<a name="l00212"></a>00212     x4 = mo2.<a class="code" href="class_moving_object.html#a51fd06046cbdff9cd1100b80e5b7e951">getWp</a>().<a class="code" href="class_way_point.html#af8e925a0c05154820837e21852cf08a5" title="Get X-coordinaat.">getX</a>();
<a name="l00213"></a>00213     y4 = mo2.<a class="code" href="class_moving_object.html#a51fd06046cbdff9cd1100b80e5b7e951">getWp</a>().<a class="code" href="class_way_point.html#abf3b2046af024d6b2c50aacc82175b05">getY</a>();
<a name="l00214"></a>00214 
<a name="l00215"></a>00215     
<a name="l00216"></a>00216     <span class="keywordtype">int</span> d = (x1-x2)*(y3-y4) - (y1-y2)*(x3-x4);
<a name="l00217"></a>00217 
<a name="l00218"></a>00218     <span class="comment">// Evenwijdige lijnen</span>
<a name="l00219"></a>00219     <span class="keywordflow">if</span> (d == 0)
<a name="l00220"></a>00220         <span class="keywordflow">return</span> <a class="code" href="class_way_point.html">WayPoint</a>(-1,-1,0,-1);
<a name="l00221"></a>00221 
<a name="l00222"></a>00222     xr = ((x3-x4)*(x1*y2-y1*x2)-(x1-x2)*(x3*y4-y3*x4))/d;
<a name="l00223"></a>00223     yr = ((y3-y4)*(x1*y2-y1*x2)-(y1-y2)*(x3*y4-y3*x4))/d;
<a name="l00224"></a>00224 
<a name="l00225"></a>00225     <span class="keywordflow">return</span> <a class="code" href="class_way_point.html">WayPoint</a>(xr,yr,0,0);
<a name="l00226"></a>00226 }
<a name="l00227"></a>00227 
<a name="l00228"></a>00228 
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>Gegenereerd op Do 19 Mei 2011 10:15:28 voor Robocup-denayer-project-a door&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>
